package com.hnd.springframework;

import java.util.ArrayList;
import java.util.List;

public class PropertyValues {
    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    public void addPropertyValue(PropertyValue propertyValue) {
        this.propertyValueList.add(propertyValue);
    }

    public PropertyValue[] getPropertyValues() {
        //list转数组的规范
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    public Object getPropertyValue(String key) {
        for (PropertyValue propertyValue : propertyValueList) {
            if (propertyValue.getName().equals(key)) {
                return propertyValue.getValue();
            }
        }
        return null;
    }
}
